<!-- S search -->
<app-search-bar
  [submitLoading]="tableParams.loading"
  [searchOptions]="searchOptions"
  labelFlex="80px"
  (onSearch)="queryResetData($event)"
  (onReset)="queryResetData($event)"
>
</app-search-bar>
<!-- E search -->

<nz-card class="m-t-2">
  <div class="opera-wrap">
    <button
      nz-button
      nzType="primary"
      [nzLoading]="exportLoading"
      (click)="exportTableData()">
      <i nz-icon nzType="download" nzTheme="outline"></i>
      导出
    </button>
  </div>

  <div class="pagination-wrap-position p-t-10">
    <nz-table
      #basicTable
      nzSize="small"
      nzShowSizeChanger
      nzShowQuickJumper
      nzOuterBordered
      [nzScroll]="{ x: '1100px' }"
      [nzFrontPagination]="false"
      [nzLoadingDelay]="100"
      [nzLoading]="tableParams.loading"
      [nzData]="tableParams.tableData"
      [nzPageSizeOptions]="[5, 10, 20, 50, 100]"
      [nzTotal]="tableParams.total"
      [nzPageIndex]="tableParams.page"
      [nzPageSize]="tableParams.pageSize"
      [nzShowTotal]="totalTemplate"
      (nzPageIndexChange)="onPageIndexChange($event)"
      (nzPageSizeChange)="onPageSizeChange($event)"
    >
      <thead>
        <tr>
          <th nzAlign="center" nzLeft nzWidth="180px">订单号</th>
          <th nzAlign="center" nzWidth="150px">订单状态</th>
          <th nzAlign="center" nzWidth="120px">收款状态</th>
          <th nzAlign="center" nzWidth="120px">应收总额</th>
          <th nzAlign="center" nzWidth="120px">优惠总额</th>
          <th nzAlign="center" nzWidth="120px">实收总额</th>
          <th nzAlign="center" nzWidth="120px">爱豆抵扣</th>
          <th nzAlign="center" nzWidth="120px">退款总额</th>
          <th nzAlign="center" nzWidth="120px">总返还爱豆</th>
          <th nzAlign="center" nzWidth="170px">下单时间</th>
          <th nzAlign="center" nzWidth="170px">付款时间</th>
          <th nzAlign="center" nzWidth="120px">支付方式</th>
          <th nzAlign="center" nzWidth="170px">发货时间</th>
          <th nzAlign="center" nzWidth="170px">完成时间</th>
          <th nzAlign="center" nzWidth="180px">货主</th>
          <th nzAlign="center" nzWidth="250px">交易流水</th>
          <th nzAlign="center" nzWidth="120px">子订单数量</th>
          <th nzAlign="center" nzWidth="180px">父订单编号</th>
        </tr>
      </thead>

      <tbody>
        <tr *ngFor="let data of basicTable.data; let index = index;">
          <!-- 订单号 -->
          <td nzAlign="center" nzLeft>{{ data.orderNum || '-' }}</td>
          <!-- 订单状态 -->
          <td nzAlign="center">
            <span [ngStyle]="{'color': data.status | secondOrderStatus: 'color'}">
              {{ data.status | secondOrderStatus: 'label' }}
            </span>
          </td>
          <!-- 收款状态 -->
          <td nzAlign="center">
            <span [ngStyle]="{'color': data.refundState | secondReportCollectionState: 'color'}">
              {{ data.refundState | secondReportCollectionState: 'label' }}
            </span>
          </td>
          <!-- 应收总额 -->
          <td nzAlign="center">{{ data.totalPrice || '0' }}</td>
          <!-- 优惠总额 -->
          <td nzAlign="center">{{ data.favorablePrice || '0' }}</td>
          <!-- 实收总额 -->
          <td nzAlign="center">{{ data.realPrice || '0' }}</td>
          <!-- 爱豆抵扣 -->
          <td nzAlign="center">{{ data.aiDouAmount || '0' }}</td>
          <!-- 退款总额 -->
          <td nzAlign="center">{{ data.refundPrice || '0' }}</td>
          <!-- 总返还爱豆 -->
          <td nzAlign="center">{{ data.refundAiDouAmount || '0' }}</td>
          <!-- 下单时间 -->
          <td nzAlign="center">{{ data.createTime || '-' }}</td>
          <!-- 付款时间 -->
          <td nzAlign="center">{{ data.payTime || '-' }}</td>
          <!-- 支付方式 -->
          <td nzAlign="center">
            <span [ngStyle]="{'color': data.payType | secondReportPayMode: 'color'}">
              {{ data.payType | secondReportPayMode: 'label' }}
            </span>
          </td>
          <!-- 发货时间 -->
          <td nzAlign="center">{{ data.shipTime || '-' }}</td>
          <!-- 完成时间 -->
          <td nzAlign="center">{{ data.dealTime || '-' }}</td>
          <!-- 货主 -->
          <td nzAlign="center">{{ data.supplierName || '-' }}</td>
          <!-- 交易流水 -->
          <td nzAlign="center">{{ data.payOrderNum || '-' }}</td>
          <!-- 子订单数量 -->
          <td nzAlign="center">{{ data.childCount || '-' }}</td>
          <!-- 父订单编号 -->
          <td nzAlign="center">{{ data.parentOrderNum || '-' }}</td>
        </tr>
      </tbody>
    </nz-table>

    <!-- 分页template -->
    <ng-template #totalTemplate let-total>共有 {{ total }} 条</ng-template>
  </div>
</nz-card>